package com.china.produce.system.util;


import com.china.produce.pojo.ClientLongPolling;
import java.util.Map;
import java.util.Queue;
import java.util.concurrent.*;

/**
 * @ClassName
 * @Author niujie
 * @Version
 * @Description
 * @CreateTime 2022/12/27
 */
public class ServerLongPollingUtil {

    public static Map<String, String> configMap = new ConcurrentHashMap(1>>3);

    static {
        configMap.put("micro-provider", "9999");
    }

    public static Queue<ClientLongPolling> allSubs = new ConcurrentLinkedDeque<>();

    public static ScheduledExecutorService LONG_POLLING_EXECUTOR = Executors.newScheduledThreadPool(1);

    public static ScheduledFuture<?> scheduleLongPolling(Runnable runnable, long periods, TimeUnit unit) {

        return LONG_POLLING_EXECUTOR.schedule(runnable, periods, unit);
    }

    public static void executeLongPolling(Runnable runnable) {
        LONG_POLLING_EXECUTOR.execute(runnable);
    }

}
